//
//  XMPrivacySetTypeTwoCell.m
//  XMJJ_zml
//
//  Created by 丁浩 on 2025/5/21.
//

#import "XMPrivacySetTypeTwoCell.h"

@interface XMPrivacySetTypeTwoCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *subTitleLabel;
@property (nonatomic, strong) UIImageView *nextIcon;
@property (nonatomic, strong) UISwitch *swi;

@end

@implementation XMPrivacySetTypeTwoCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatUI];
    }
    return self;
}

- (void)creatUI {
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.subTitleLabel];
    [self.contentView addSubview:self.nextIcon];
    [self.contentView addSubview:self.swi];
}

- (void)setContentWithTitle:(NSString *)title
                   subTitle:(NSString *)subTitle
                       type:(NSInteger)type {
    _titleLabel.text = title;
    _subTitleLabel.text = subTitle;
    _swi.hidden = (type == 1);
    _nextIcon.hidden = (type == 0);
}

#pragma mark - Init
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(KScaleWidth(16.0), 0, kScreenWidth - KScaleWidth(16.0) - KScaleWidth(85.0), KScaleWidth(45.0)) font:KFontSize(17.0) textColor:kColorHEX(0x333333)];
    }
    return _titleLabel;
}

- (UILabel *)subTitleLabel {
    if (!_subTitleLabel) {
        _subTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth/2, 0, kScreenWidth/2 - KScaleWidth(33.0), KScaleWidth(45.0)) font:KFontSize(15.0) textColor:kColorHEX(0x666666) textAlignment:NSTextAlignmentRight];
    }
    return _subTitleLabel;
}

- (UIImageView *)nextIcon {
    if (!_nextIcon) {
        _nextIcon = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth - KScaleWidth(14.0) - KScaleWidth(14.0), KScaleWidth(16.0), KScaleWidth(14.0), KScaleWidth(14.0))];
        _nextIcon.image = ImageNamed(@"mine_detail_icon");
    }
    return _nextIcon;
}

- (UISwitch *)swi {
    if (!_swi) {
        _swi = [[UISwitch alloc] initWithFrame:CGRectMake(kScreenWidth - KScaleWidth(16.0) - KScaleWidth(42.0), (KScaleWidth(45.0) - KScaleWidth(20.0))/2, KScaleWidth(42.0), KScaleWidth(20.0))];
        _swi.y = (KScaleWidth(45.0) - _swi.height)/2;
        _swi.x = kScreenWidth - KScaleWidth(15.0) - _swi.width;
        [_swi setTintColor:kColorHEX(0x999999)];
        [_swi setOnTintColor:kColorHEX(0xFFD800)];
    }
    return _swi;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
